




export default {
  bind(el, binding, vnode) {
    const selectInputDom = el.querySelector('input')
    const observer = (() => {
      if (!window.MutationObserver) return;
      return new MutationObserver((e) => {
        e.forEach(item => {
          if (item.type === 'attributes' && item.attributeName === 'readonly') {
            setTimeout(() => item.target.removeAttribute('readonly'), 20)
          }
        })
      });
    })()

    selectInputDom.removeAttribute('readonly')
    if (observer) {
      el.observer = observer
      observer.observe(selectInputDom, {
        attributes: true,
      })
    }
  },
  unbind(el, binding) {
    if (el.observer) {
      el.observer.disconnect()
    }
  }
}
